<template>
  <div class="wrapper">
    <div class="toast">{{ message }}</div>
  </div>
</template>

<script>
import { reactive, toRefs } from 'vue';

export default {
  name: 'Toast',
  props: ['message'],
  setup() {
    // console.log(props);
  },
};
export const useToastEffect = () => {
  const toastData = reactive({
    show: false,
    toastMessage: '',
  });
  const showToast = (msg) => {
    toastData.show = true;
    toastData.toastMessage = msg;
    setTimeout(() => {
      toastData.show = false;
      toastData.toastMessage = '';
    }, 2000);
  };

  const { show, toastMessage } = toRefs(toastData);
  return { show, toastMessage, showToast };
};
</script>

<style lang="scss" scoped>
@import '../style/variables.scss';

.wrapper {
  width: 100%;
  height: 100%;
  background: rgba($color: #000000, $alpha: 0.3);
}

.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  padding: 0.5rem;
  background: rgba($color: #000000, $alpha: 0.3);
  border-radius: 0.05rem;
  color: $bgColor;
}
</style>
